package park.job;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

import com.google.gson.Gson;

import park.record.EntryRecord;

public class ToolUtil{

	public static String test_data_path = "D:/TestTool/parkpresstest/testData";

	/** The cfg name. */
	public static String entryRecordFile = "entryRecord.txt";
	public static String exitRecordFile = "exitRecord.txt";
	public static String confirmRecordFile = "confirmEntryRecord.txt";

	public static String readConfig(String cfgPath) throws IOException {
		BufferedReader br = new BufferedReader(new FileReader(cfgPath));
		String line = "";
		StringBuffer sb = new StringBuffer();
		while ((line = br.readLine()) != null) {
			if (!line.trim().startsWith("//"))
				sb.append(line);
		}
		br.close();
		return sb.toString();
	}

	public static <T> T getData(String path,  Class<T> t) {
		// TODO Auto-generated method stub
		String readFileString;
		T re = null;
		try {
			readFileString = readConfig(path);
			Gson gson=new Gson();
			re =  gson.fromJson(readFileString, t);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		return re;
	
	}
	
	

}
